<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>签名表格</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link href="../../layui/css/iconfont/iconfont.css" rel="stylesheet"
          type="text/css">
    <link href="../../layui/css/layui.css" rel="stylesheet" type="text/css">
    <link href="../../css/style.css" rel="stylesheet" type="text/css">
    <link href="../../css/jquery-ui-1.10.4.custom.min.css" rel="stylesheet"
          type="text/css">
    <script src="../../layui/layui.js"></script>
    <script src="../../js/jquery-1.8.3.js"></script>
    <script src="../../js/util.js"></script>
    <script src="../../js/jquery-ui-1.10.4.custom.min.js"></script>
    <script type="text/javascript">
        layui.use(['form', 'table', 'jquery', 'element', 'laydate', 'layer'], function () {
            var form = layui.form;
            var $ = layui.$;
            var laydate = layui.laydate;
            var layer = layui.layer;
            var table = layui.table;
            laydate.render({
                elem: '#sendTime'
                , type: 'date'
            });
            var tableDate = {
                elem: "#table",//表格id
                id: "modelReload", //id
                url: '/signatureManage/qrySignatureList',
                method: 'post',
                request: {
                    page: "page",
                    limit: "limit",
                    cityId: $("#cityId").val(),
                    countyId: $("#countyId").val()
                },
                async: false,
                contentType: "application/json;charset=UTF-8",
                // response: {
                //     statusName: 'code',
                //     statusCode: 0,
                //     msgName: 'msg',
                //     countName: 'count',
                //     dataName: 'data'
                // },
                page: true,
                count: "count",
                limit: 10,
                limits: [10, 20, 30, 40, 50],
                layout: ['prev', 'page', 'next'],
                prev: "上一页",
                next: "下一页",
                cols: [[ //表头
                    {
                        field: 'cityName', title: '地市/区县', templet: function (d) {
                            return d.cityName + "/" + d.countyName;
                        }
                    }
                    , {field: 'signName', title: '签名'}
                    , {field: 'ecName', title: '归属集团'}
                    , {field: 'smsChannelNumber', title: '短信通信号'}
                    , {
                        field: 'checkState', title: '签名审核状态', templet: function (d) {
                            if (d.checkState == '0') {
                                return '<div style="color:grey;">待审核</div>';
                            } else if (d.checkState == '1') {
                                return '<div style="color:green;">审核通过</div>';
                            } else if (d.checkState == '-1') {
                                return '<div style="color:red;">审核不通过</div>';
                            }

                        }
                    }, {
                        field: 'openCount', title: '签名开户状态', templet: function (d) {
                            if (d.openAccount == '0') {
                                return '<div style="color:grey;">未开户</div>';
                            } else if (d.openAccount == '1') {
                                return '<div style="color:green;">已开户</div>';
                            }

                        }
                    }, {
                        field: 'isArrearage', title: '签名欠费状态', templet: function (d) {
                            if (d.isArrearage == '0') {
                                return '<div style="color:green;">未欠费</div>';
                            } else if (d.isArrearage == '1') {
                                return '<div style="color:red;">已欠费</div>';
                            }

                        }
                    }, {
                        field: 'hasAttachment', title: '是否上传授权书', templet: function (d) {
                            if (d.hasAttachment == '0') {
                                return '<div style="color:grey;">未上传</div>';
                            } else if (d.hasAttachment == '1') {
                                return '<div style="color:grey;">已上传</div>';
                            }

                        }
                    }
                    , {field: 'operation', title: '操作', toolbar: '#barDemo'}
                ]], done: function (res, curr, count) {
                }
            };

            table.on('tool(tableElement)', function (obj) {
                var data = obj.data;
                console.log(obj);
                if (obj.event == 'check') {
                    window.location.href = 'smsTemplateSignture.html?signId=' + data.signId;
                    return false;
                } else if (obj.event === 'delete') {
                    layer.confirm('您确定要删除该签名吗', {icon: 3, title: '提示'}, function (index) {
                        var url = "/signatureManage/remove";
                        var param = {
                            signId: data.signId
                        };
                        $.ajax({
                            type: 'post',
                            data: param,
                            url: url,
                            beforeSend: function () {
                            },
                            success: function (data) {
                                if (data >= 1) {
                                    layer.confirm('删除成功', {
                                        btn: ['确认'] //按钮
                                    }, function () {
                                        location.href = "signatureTable.html";
                                    });
                                } else {
                                    layer.confirm('删除失败，请重试', {
                                        btn: ['确认'] //按钮
                                    }, function () {
                                        location.href = "signatureTable.html";
                                    });
                                }
                            },
                            complete: function () {
                            }
                        });
                    });

                } else if (obj.event === 'reApply') {
                    layer.confirm('您确定要重新发起审核申请吗', {icon: 3, title: '提示'}, function (index) {
                        var url = "/signatureManage/reApply";
                        var param = {
                            signId: data.signId
                        };
                        $.ajax({
                            type: 'post',
                            data: param,
                            url: url,
                            beforeSend: function () {
                            },
                            success: function (data) {
                                if (data.retCode == 0) {
                                    layer.confirm('发起申请成功', {
                                        btn: ['确认'] //按钮
                                    }, function () {
                                        location.href = "signatureTable.html";
                                    });
                                } else {
                                    layer.confirm('发起申请失败，请重试', {
                                        btn: ['确认'] //按钮
                                    }, function () {
                                        location.href = "signatureTable.html";
                                    });
                                }
                            },
                            complete: function () {
                            }
                        });
                    });

                }


            });


            table.render(tableDate);

            $(document).ready(function () {
                $.ajax({
                    type: 'post',
                    async: false,
                    url: '/util/findUser',
                    success: function (json) {
                        if (json.duty == 1) {
                            $("#cityId").val(json.cityId);
                            $("#cityId").attr("disabled", true);
                            var data2 = selectCountyId(json.cityId);
                            appendCounty(data2);
                            form.render();
                        } else if (json.duty == 2) {
                            $("#cityId").val(json.cityId);
                            $("#cityId").attr("disabled", true);
                            var data2 = selectCountyId(json.cityId);
                            appendCounty(data2);
                            $("#countyId").val(json.countyId);
                            $("#countyId").attr("disabled", true);
                            form.render();
                        }

                        var cityId = $("#cityId").val();
                        var countyId = $("#countyId").val();
                        var signName = $("#signName").val();
                        var ecName = $("#ecName").val();
                        var checkState = $("#checkResult").val();
                        var index = layer.load(1, {
                            shade: [0.1, '#fff'] //0.1透明度的白色背景
                        });
                        table.reload('modelReload', {
                            method: 'post',
                            page: {
                                curr: 1
                            },
                            where: {
                                cityId: cityId,
                                countyId: countyId,
                                signName: signName,
                                ecName: ecName,
                                checkState: checkState
                            }
                        });

                        layer.close(index);

                    }, error: function () {
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                });
            })
                //
                // $(document).on('click',"#downLoad",function(){
                //     var url = '/pdf/2021062115244639.pdf';
                //     window.open(url);
                // });


                $('#query').on('click', function () {
                    var cityId = $("#cityId").val();
                    var countyId = $("#countyId").val();
                    var signName = $("#signName").val();
                    var ecName = $("#ecName").val();
                    var checkState = $("#checkResult").val();
                    var index = layer.load(1, {
                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                    });
                    table.reload('modelReload', {
                        method: 'post',
                        page: {
                            curr: 1
                        },
                        where: {
                            cityId: cityId,
                            countyId: countyId,
                            signName: signName,
                            ecName: ecName,
                            checkState: checkState
                        }
                    });
                    layer.close(index);
                });
                $('#add').on('click', function () {
                    location.href = "createReport.html"
                });


                //动态拼接区县
                function appendCounty(data) {
                    if (data.length != null) {
                        var options = '<option value="">请先选择地市</option>';
                        for (var i = 0; i < data.length; i++) {
                            options += '<option value="' + data[i].countyId + '">' + data[i].countyName + '</option>';
                        }
                        $('#countyId').html(options);
                    } else {
                        $('#countyId').html('该地市下没有区县');
                    }
                    form.render();
                }

                //根据城市ID查询区县
                function selectCountyId(cityId) {
                    var data;
                    var url = '/util/findCountyByCityId?cityId=' + cityId;
                    $.ajax({
                            type: 'post',
                            async: false,
                            url: url,
                            success: function (json) {
                                data = json.data;
                            }, error: function () {
                                layer.msg('系统异常，请联系管理员处理!');
                            }
                        }
                    );
                    return data;
                };
                //监听项目  区县
                form.on('select(cityId)', function (data) {
                    var data2 = selectCountyId(data.value);
                    appendCounty(data2);
                });
            });


    </script>
    <script type="text/html" id="barDemo">

        <a href="#" lay-event="check" id="check" style="color:blue;">查看</a>
        <a href="#" lay-event="delete" id="delete"  style="color:blue;">删除</a>
        {{# if (d.checkState=='-1'){}}
        <a href="#" lay-event="reApply" id="reApply"  style="color:blue;">重新发起申请</a>
        {{#}}}

    </script>
    <!-- 填写用户信息弹窗模板 -->
    <script type="text/html" id="detail">
        <div id="popup-userInfo" style="overflow: hidden;">
            <div class="m_item">
                <span class="require" style="width: 10%;">学号</span>
            </div>
            <div class="m_item">
                <span class="require" style="width: 10%;">姓名</span>
            </div>
            <div class="m_item">
                <span class="require" style="width: 10%;">手机号</span>
            </div>
            <div class="m_item ">
                <span class="require" style="width: 10%;">学院</span>
            </div>
            <div class="m_item ">
                <span class="require" style="width: 10%;">专业</span>
            </div>
            <div class="m_item">
                <span class="require" style="width: 10%;">年级</span>
            </div>
            <div class="m_item">
                <span class="require" style="width: 10%;">邮箱</span>
            </div>
        </div>
    </script>


</head>
<body>
<div class="layui-content-body">
    <div class="scroll-box">
        <div class="breadcrumb-box">
				<span class="layui-breadcrumb" lay-separator="|"><a
                        href="javascript:returnIndex2()">首页&nbsp;</a> <a href="">&nbsp;签名管理&nbsp;</a>
				</span>
        </div>
        <div class="content-box">
            <div class="form-select-box">
                <div class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">地市:</label>
                            <div class="layui-input-block" style="width:150px">
                                <select name="cityId" lay-filter="cityId" id="cityId">
                                    <option value="">请选择</option>
                                    <option value="11">苏州</option>
                                    <option value="12">淮安</option>
                                    <option value="13">宿迁</option>
                                    <option value="14">南京</option>
                                    <option value="15">连云港</option>
                                    <option value="16">徐州</option>
                                    <option value="17">常州</option>
                                    <option value="18">镇江</option>
                                    <option value="19">无锡</option>
                                    <option value="20">南通</option>
                                    <option value="21">泰州</option>
                                    <option value="22">盐城</option>
                                    <option value="23">扬州</option>
                                    <option value="25">省级</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline countyId">
                            <label class="layui-form-label">区县:</label>
                            <div class="layui-input-block" style="width:110px">
                                <select name="countyId" lay-filter="countyId" id="countyId">
                                    <option value="">全部</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">签名:</label>
                            <div class="layui-input-block" style="width:150px">
                                <input type="text" name="sign" required  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" id="signName">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">集团名称:</label>
                            <div class="layui-input-block" style="width:150px">
                                <input type="text" name="sign" required  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" id="ecName">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">审核状态:</label>
                            <div class="layui-input-block" style="width:150px">
                                <select id="checkResult" name="checkResult"
                                        lay-filter="checkResult">
                                    <option value="">请选择</option>
                                    <option value="0">待审核</option>
                                    <option value="1">审核通过</option>
                                    <option value="-1">审核不通过</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <div class="layui-inline" pane="">
                                <button class="layui-btn layui-btn-normal" id="query">查&nbsp;询</button>
                                <button class="layui-btn layui-btn-normal" id="add">新 增</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-table">
                <table id="table" lay-filter="tableElement"></table>
            </div>
        </div>
    </div>
</div>
</body>
</html>